<template>
  <div class="app-container cmlp">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="150px">
      <el-form-item label="User_ID" prop="userId">
        <el-input
          v-model="queryParams.userId"
          placeholder="Please enter User_ID"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="Customer NO." prop="custNo">
        <el-input
          v-model="queryParams.custNo"
          placeholder="Please enter Customer NO."
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="BVN" prop="bvn">
        <el-input
          v-model="queryParams.bvn"
          placeholder="Please enter BVN"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="Full Name" prop="clientName">
        <el-input
          v-model="queryParams.clientName"
          placeholder="Please enter Full Name"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="First name" prop="firstName">
        <el-input
          v-model="queryParams.firstName"
          placeholder="Please enter First name"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="Last name" prop="lastName">
        <el-input
          v-model="queryParams.lastName"
          placeholder="Please enter Last name"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="Registration mobile" prop="mobile">
        <el-input
          v-model="queryParams.mobile"
          placeholder="Please enter Registration mobile #"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="Registration time">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="start time"
          end-placeholder="End time"
        ></el-date-picker>
      </el-form-item>
      <!-- <el-form-item label="*">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">Search</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">Re-set</el-button>
      </el-form-item> -->
      <div class="t_c">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">Search</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">Re-set</el-button>
      </div>
    </el-form>

    <el-table v-loading="loading" :data="typeList" :stripe='true'>
      <!-- <el-table-column type="selection" width="55" align="center"/> -->
      <el-table-column label="#" type="index" align="center" show-overflow-tooltip width="50px"></el-table-column>
      <!--      <el-table-column label="CustNo" align="center" prop="custNo"/>-->
      <el-table-column label="User_ID" align="center" prop="userId"/>
      <el-table-column label="Customer NO." align="center" prop="custNo"/>
      <el-table-column label="Client name" align="center" prop="clientName"/>
      <el-table-column label="BVN" align="center" prop="bvn"/>
      <el-table-column label="Mobile #" align="center" prop="mobile"/>
      <el-table-column label="Status" align="center" prop="state"/>
<!--      <el-table-column label="Outstanding amount" align="center" prop="outstandingAmount"/>-->
      <el-table-column label="Operating" align="center" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <router-link :to="'/cust_management_loan_page/data/' + scope.row.custNo" class="link-type">
            <el-button
              type="warning"
              plain
              icon="el-icon-view"
              v-hasPermi="['business:customer:detail']"
              size="mini"
            >Details
            </el-button>
          </router-link>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>

import {getCustomerList} from "@/api/bizsys/cust_management_loan_page";

export default {
  name: "Cust_management_loan_page",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 字典表格数据
      typeList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 状态数据字典
      statusOptions: [],
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        bvn: '',
        mobile: '',
        firstName:'',
        lastName:'',
        userId:'',
        custNo:'',
        clientName:'',
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        dictName: [
          {required: true, message: "Mobile #不能为空", trigger: "blur"}
        ],
        dictType: [
          {required: true, message: "字典类型不能为空", trigger: "blur"}
        ]
      },
      messageStatus:'',
    };
  },
  created() {
     // this.getList();
    this.getDicts("sys_normal_disable").then(response => {
      this.statusOptions = response.data;
      this.loading = false;
    });
  },
  methods: {
    /** 查询客户列表 */
    getList() {
      if(this.queryParams.bvn =='' && this.queryParams.mobile =='' &&this.queryParams.firstName =='' &&this.queryParams.lastName =='' &&this.queryParams.userId =='' &&this.queryParams.custNo ==''&&this.queryParams.clientName =='' &&this.dateRange.length ==0 ){
          if(this.messageStatus != ''){
            this.messageStatus.close()
          }
          this.messageStatus = this.$message({
            message: 'Please enter the content to search',
            type: 'warning'
          });
          this.typeList = [];
          this.total = 0;
          return
      }else{
         this.loading = true;
          getCustomerList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
              this.typeList = response.rows;
              this.total = response.total;
              this.loading = false;
            }
          );
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      // this.handleQuery();
    }
  }
};
</script>
<style scoped>

</style>
<style type="text/css" >
  .cmlp .el-form .el-form-item .el-form-item__label{
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #2C3C3C !important;
  }
  .t_c{
    widows: 100%;
    text-align: center;
    margin-bottom: 22px;
  }
  .cmlp .el-form .el-button--primary,
  .cmlp .el-form .el-button--primary:hover{
    border: 1px solid #EADD07;
    background: #EADD07;
    font-family: Microsoft YaHei;
    color: #2C3C3C;
  }
  .cmlp .el-form .el-button + .el-button,
  .cmlp .el-form .el-button + .el-button:hover{
    border: 1px solid #EADD07;
    color: #EADD07;
    background: #ffffff;
  }

  .el-table{
    color: #2c3c3c;
  }
  .el-table th > .cell{
    color: #2c3c3c;
    font-weight: 400;
  }
  .el-table .el-table__header-wrapper th{
    background-color: #FFFEEB;
  }
  .el-table th.is-leaf, .el-table td{
    border-bottom: 0px solid #dfe6ec !important;
  }
  .el-table--striped .el-table__body tr.el-table__row--striped td{
    background: #f5f5f5;
  }
  .el-pagination.is-background .el-pager li:not(.disabled).active{
    background-color: #EADD07;
    color: #FFFFFF;
  }
  .el-pagination.is-background .btn-prev, .el-pagination.is-background .btn-next, .el-pagination.is-background .el-pager li{
    background-color: transparent
  }
</style>
